Re: [SQL] Week of year function?

Поиск
Список
Период
Сортировка
От Herouth Maoz
Тема Re: [SQL] Week of year function?
Дата
Msg-id l03130302b43a3e85e018@[147.233.159.109]
обсуждение исходный текст
Ответ на Week of year function?  ("Zot O'Connor" <zot@zotconsulting.com>)
Список pgsql-sql
At 21:52 +0200 on 22/10/1999, Zot O'Connor wrote:


> Is there a function to return the week of the year (0-51)?

Seems you only need to divide the day of the year by seven to reach that,
don't you?

Maybe you should try:

CREATE FUNCTION week( datetime ) RETURNS int4 AS ' SELECT int( date_part( ''day'', $1 - date_trunc( ''year'', $1 ) ) )
/7
 
' LANGUAGE 'sql';

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma




В списке pgsql-sql по дате отправления:

Предыдущее
От: Rich Ryan
Дата:
Сообщение: Create index pretty slow
Следующее
От: "Moray McConnachie"
Дата:
Сообщение: Re: [SQL] Week of year function?